import React, { Component } from 'react'
import { connect } from "react-redux"
import {action,action2} from "@/redux/actions"

class Salary extends Component {
  componentDidMount() {
    console.log(this);
  }
  changeCount = () => {
    //this.props.dispatch(action(50))
    this.props.dispatch({
      type: "INCREMENT",
      payload: 50
    })
  }
  render() {
    return (
      <div>
        <h3>Salary</h3>
        <p>{this.props.state.count}</p>
        <button onClick={this.changeCount}>修改count</button>
      </div>
    )
  }
}
//函数名字可以自己定义
const mapStateToProps = (state) => {
  return {
    state: state.countRD
  }
}
export default connect(mapStateToProps)(Salary)

// function connect(){
//   return function(component){
//     //React.createElement("Salary",{xxx},)
//     //component 动态给这个组件添加 dispatch
//     // const dispatch = store.dispatch
//     return component
//   }
// }